package com.gilgamesh.mall.product.controller;

import com.gilgamesh.mall.product.dao.ShopDao;
import com.gilgamesh.mall.product.service.ShopService;
import com.gilgamesh.mall.sdk.bean.product.ShopEntity;
import com.gilgamesh.mall.sdk.dto.ResponseDTO;
import com.gilgamesh.mall.sdk.dto.product.ShopDTO;
import com.gilgamesh.mall.sdk.util.ResponseUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author yanm
 * @date 2021/1/20 16:04
 **/
@RestController
@RequestMapping("api/pdt")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@CrossOrigin
public class ShopController {
    private final ShopService shopService;

    @PostMapping("createShop")
    public ResponseDTO<Integer> createShop(@RequestParam(value = "shopName",required = false) String shopName){
        System.out.println("接口createShop = "+shopName);
        ShopEntity shopEntity = new ShopEntity();
        shopEntity.setShopName(shopName);
        shopEntity.setCreateTime(new Date());
        return shopService.createShop(shopEntity);
    }

    @PostMapping("listShop")
    public ResponseDTO<List<ShopDTO>> listShop(){
        return shopService.listShopDTO(null);
    }


}
